package top.lucas9.wechat.push.common;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 天气api枚举类
 *
 * @author lucas9
 * @date 2024/10/12 0:18
 */
@AllArgsConstructor
@Getter
public enum WeatherApiEnum {
    /**
     * 三天天气
     */
    THREE_DAY("3d", "3天预报"),

    /**
     * 7天预报
     */
    SEVEN_DAY("7d", "7天预报"),

    /**
     * 实时天气
     */
    NOW("now", "实时天气");

    /**
     * api名称
     */
    private final String api;
    /**
     * api描述
     */
    private final String desc;

    /**
     * 根据api获取枚举
     *
     * @param api
     * @return
     */
    public static WeatherApiEnum getByApiValue(String api) {
        switch (api) {
            case "3d":
                return THREE_DAY;
            case "7d":
                return SEVEN_DAY;
            case "now":
                return NOW;
            default:
                throw new IllegalArgumentException("不支持的API类型：" + api);
        }
    }
}
